package com.graficaluna.dao.otros;

import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;


public class MyBatisConnectionFactory {

	private static SqlSessionFactory sqlSessionFactory;

	static {
            try {              
                Reader reader = Resources.getResourceAsReader("mybatis/configuracion/configurationIbatis.xml");
                //patron singleton
                if (sqlSessionFactory == null) {
                    sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
                }
            } catch (Exception e) {
                System.out.println("ERROR CONECTANDOSE...........................");
                e.printStackTrace();
            }
        }

	public static SqlSessionFactory getSqlSessionFactory() {
		return sqlSessionFactory;
	}

}
